#ifndef __SUBSYSTEM_BASE_ITEM_H__
#define __SUBSYSTEM_BASE_ITEM_H__

#include "Subsystems/Subsystem.hpp"
#include <vector>
#include <unordered_map>
#include <list>
#include <mutex>

namespace PocketSurvival
{
    class GameManager;
}

using namespace PocketSurvival;

namespace BaseItem
{
    struct BaseSlot
    {
        int32_t value;
        uint32_t count;

        BaseSlot() = default;
        constexpr inline BaseSlot(int32_t theValue, uint32_t theCount) : value(theValue), count(theCount) {}

        friend inline void to_json(nlohmann::json &json, const BaseSlot &baseSlot)
        {
            json = {{"value", baseSlot.value},{"count", baseSlot.count}};
        }
        friend inline void from_json(const nlohmann::json &json, BaseSlot &baseSlot)
        {
            baseSlot.value = json["value"].get<int32_t>();
            baseSlot.count = json["count"].get<uint32_t>();
        }
    };

    class SubsystemBaseItem : public Subsystem
    {
    public:
        SubsystemBaseItem();

        virtual const std::string& getName() const override;
        virtual void update(float dt) override;
        virtual void load(const nlohmann::json& json) override;
        virtual void save(nlohmann::json& json) override;
        virtual void saveToMsgJson(nlohmann::json &jsonData) override;

        virtual void onEntityAdded(entt::entity entity) override;

    protected:
        std::vector<std::vector<int32_t>> m_baseClothes;
        std::vector<BaseSlot> m_baseSlots;

        GameManager *m_gameManager;
    };

    inline SubsystemBaseItem::SubsystemBaseItem() {}
}

#endif